﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EffiProz.Core.Lib;
using EffiProz.Core.DataTypes;
using EffiProz.Core.Errors;

namespace EffiProz.Core.RowIO
{
    public class RowOutputBinary180 : RowOutputBinary
    {
        public RowOutputBinary180(int initialSize, int scale)
            : base(initialSize, scale)
        {
        }

        protected override void writeDate(TimestampData o, SqlType type)
        {
            writeLong(o.getSeconds() * 1000L);
        }

        protected override void writeTime(TimeData o, SqlType type)
        {

            if (type.typeCode == Types.SQL_TIME)
            {
                writeLong(o.getSeconds() * 1000L);
            }
            else
            {
                writeInt(o.getSeconds());
                writeInt(o.getNanos());
                writeInt(o.getZone());
            }
        }

        protected override void writeTimestamp(TimestampData o, SqlType type)
        {

            if (type.typeCode == Types.SQL_TIMESTAMP)
            {
                writeLong(o.getSeconds() * 1000L);
                writeInt(o.getNanos());
            }
            else
            {
                writeLong(o.getSeconds());
                writeInt(o.getNanos());
                writeInt(o.getZone());
            }
        }
    }
}
